package com.rjxy.plansystemmanagement.service.impl;

import com.rjxy.plansystemmanagement.entity.U_file;
import com.rjxy.plansystemmanagement.mapper.UFileMapper;
import com.rjxy.plansystemmanagement.service.UFileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UFileServiceImpl implements UFileService {
    @Autowired
    private UFileMapper uFileMapper;

    @Override
    public U_file getUFileByUId(Integer uid) {
        return uFileMapper.getUFileByUId(uid);
    }

    @Override
    public boolean saveOrUpdateAvatar(U_file uFile) {
        // 根据需求添加插入或更新逻辑
        // 示例：先查询是否存在，再决定插入或更新
        U_file existing = uFileMapper.getUFileByUId(uFile.getUid());
        if (existing != null) {
            return uFileMapper.updateAvatar(uFile) > 0; // 更新头像
        } else {
            return uFileMapper.insertAvatar(uFile) > 0; // 插入新记录
        }
    }
}
